<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
  http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

    <!-- Определение таблицы app_user -->
    <changeSet id="1" author="wvbaymler">
        <createTable tableName="app_user">
            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="username" type="varchar(50)">
                <constraints nullable="false"/>
            </column>
            <column name="email" type="varchar(255)">
                <constraints nullable="false"/>
            </column>
            <column name="password" type="varchar(255)">
                <constraints nullable="false"/>]
            </column>
        </createTable>
    </changeSet>

    <!-- Определение таблицы wallet -->
    <changeSet id="2" author="wvbaymler">
        <createTable tableName="wallet">
            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="user_id" type="bigint">
                <constraints nullable="false"/>
            </column>
            <column name="balance" type="decimal(19,4)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <!-- Определение таблицы currency -->
    <changeSet id="3" author="wvbaymler">
        <createTable tableName="currency">
            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="name" type="varchar(50)">
                <constraints nullable="false"/>
            </column>
            <column name="symbol" type="varchar(10)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <!-- Определение таблицы transaction -->
    <changeSet id="4" author="wvbaymler">
        <createTable tableName="transaction">
            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="wallet_id" type="bigint">
                <constraints nullable="false"/>
            </column>
            <column name="currency_id" type="bigint">
                <constraints nullable="false"/>
            </column>
            <column name="amount" type="decimal(19,4)">
                <constraints nullable="false"/>
            </column>
            <column name="transaction_type" type="varchar(10)">
                <constraints nullable="false"/>
            </column>
            <column name="timestamp" type="timestamp">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <!-- Определение таблицы deal -->
    <changeSet id="5" author="wvbaymler">
        <createTable tableName="deal">
            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="timestamp" type="timestamp">
                <constraints nullable="false"/>
            </column>
            <column name="amount" type="decimal(19,4)">
                <constraints nullable="false"/>
            </column>
            <column name="price" type="decimal(19,4)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <!-- Определение таблицы pocket -->
    <changeSet id="6" author="wvbaymler">
        <createTable tableName="pocket">
            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="balance" type="decimal(19,4)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <!-- Определение таблицы user_data -->
    <changeSet id="7" author="wvbaymler">
        <createTable tableName="user_data">
            <column name="id" type="bigint" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="first_name" type="varchar(255)">
                <constraints nullable="false"/>
            </column>
            <column name="last_name" type="varchar(255)">
                <constraints nullable="false"/>
            </column>
            <column name="phone_number" type="varchar(20)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <changeSet id="8" author="wvbaymler">
        <insert tableName="app_user">
            <column name="id" valueNumeric="1"/>
            <column name="username" value="user1"/>
            <column name="email" value="user1@example.com"/>
            <column name="password" value="pass1"/>
        </insert>
        <insert tableName="app_user">
            <column name="id" valueNumeric="2"/>
            <column name="username" value="user2"/>
            <column name="email" value="user2@example.com"/>
            <column name="password" value="pass2"/>
        </insert>
    </changeSet>

    <changeSet id="9" author="wvbaymler">
        <insert tableName="wallet">
            <column name="id" valueNumeric="1"/>
            <column name="user_id" valueNumeric="1"/>
            <column name="balance" valueNumeric="1000.00"/>
        </insert>
        <insert tableName="wallet">
            <column name="id" valueNumeric="2"/>
            <column name="user_id" valueNumeric="2"/>
            <column name="balance" valueNumeric="1500.00"/>
        </insert>
    </changeSet>

    <changeSet id="10" author="wvbaymler">
        <insert tableName="currency">
            <column name="id" valueNumeric="1"/>
            <column name="name" value="Bitcoin"/>
            <column name="symbol" value="BTC"/>
        </insert>
        <insert tableName="currency">
            <column name="id" valueNumeric="2"/>
            <column name="name" value="Ethereum"/>
            <column name="symbol" value="ETH"/>
        </insert>
    </changeSet>

</databaseChangeLog>